﻿using Cofe.Core.Property;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace Cofe.Core.Security
{
    ///// <summary>
    ///// Allow service to have all permission.
    ///// </summary>
    ///// <typeparam name="T"></typeparam>
    //public class ServicePermissionPolicy<T> : IPermissionPolicy<T>, IXmlSerializable
    //    where T : IProtectedData<T>
    //{
    //    public ServicePermissionPolicy(PermissionType permissionType = PermissionType.All)
    //    {
    //        _permissionType = permissionType;
    //    }

    //    public ServicePermissionPolicy()
    //    {            
    //    }


    //    public void ReadXml(System.Xml.XmlReader reader)
    //    {
    //        reader.MoveToContent();

    //        reader.MoveToContent();

    //        _permissionType = (PermissionType)Int32.Parse(reader.GetAttribute("Permission"));            
    //    }

    //    public void WriteXml(System.Xml.XmlWriter writer)
    //    {
    //        writer.WriteAttributeString("Permission", ((int)_permissionType).ToString());         
    //    }

    //    public System.Xml.Schema.XmlSchema GetSchema()
    //    {
    //        throw new NotImplementedException();
    //    }

    //    private PermissionType _permissionType;

    //    public bool Match(T requestedObj, PermissionType permissionType)
    //    {
    //        if (_permissionType.HasFlag(permissionType))
    //            return true;
    //        else return false;
    //    }

    //    public string[] RequiredRole { get { return new string[] { SecurityConstants.ServiceRole }; } }        
    //}
}
